package com.topscomm.base.operation;

import java.util.List;
import java.util.concurrent.CountDownLatch;

import com.topscomm.basic.BasicEntity;
import com.topscomm.tap.TapService;

/**
 * 线程任务
 * 
 * @description:
 * @author: donghang
 * @date: 2020年10月28日下午6:56:47
 * @modify:
 */
public class BaseBatchTask implements Runnable {
	private List<BasicEntity> dataList;
	private CountDownLatch countDownLatch;
	private TapService<?, ?> tapService;

	public BaseBatchTask(List<BasicEntity> mdataList, TapService<?, ?> mtapService, CountDownLatch countDownLatch) {
		this.dataList = mdataList;
		this.countDownLatch = countDownLatch;
		this.tapService = mtapService;
	}

	/**
	 * 线程运行处理具体业务
	 * 
	 * @description:
	 * @author: donghang
	 * @date: 2020年10月28日下午7:09:50
	 * @modify:
	 */
	@Override
	public void run() {
		if (null != this.dataList) {
			// 业务逻辑，例如批量insert或者update
			tapService.insertBatch(this.dataList);
		}
		// 发出线程任务完成的信号
		countDownLatch.countDown();
	}
}
